{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "code",
      "source": [
        "!pip install -q langchain-nebius langchain-core langchain-community wikipedia\n",
        "\n",
        "import os\n",
        "import getpass\n",
        "from typing import List, Dict, Any\n",
        "import wikipedia\n",
        "from datetime import datetime"
      ],
      "metadata": {
        "id": "eK6yiSR71Km6"
      },
      "execution_count": 2,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "from langchain_core.documents import Document\n",
        "from langchain_core.prompts import ChatPromptTemplate\n",
        "from langchain_core.output_parsers import StrOutputParser\n",
        "from langchain_core.runnables import RunnablePassthrough\n",
        "from langchain_core.tools import tool\n",
        "from langchain_nebius import ChatNebius, NebiusEmbeddings, NebiusRetriever\n",
        "\n",
        "if \"NEBIUS_API_KEY\" not in os.environ:\n",
        "    os.environ[\"NEBIUS_API_KEY\"] = getpass.getpass(\"Enter your Nebius API key: \")"
      ],
      "metadata": {
        "id": "lI65mzyx1LX6"
      },
      "execution_count": 3,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "class AdvancedNebiusAgent:\n",
        "    \"\"\"Advanced AI Agent with retrieval, reasoning, and external tool capabilities\"\"\"\n",
        "\n",
        "    def __init__(self):\n",
        "        self.llm = ChatNebius(model=\"meta-llama/Llama-3.3-70B-Instruct-fast\")\n",
        "        self.embeddings = NebiusEmbeddings()\n",
        "        self.knowledge_base = self._create_knowledge_base()\n",
        "        self.retriever = NebiusRetriever(\n",
        "            embeddings=self.embeddings,\n",
        "            docs=self.knowledge_base,\n",
        "            k=3\n",
        "        )\n",
        "\n",
        "        self.agent_prompt = ChatPromptTemplate.from_template(\"\"\"\n",
        "You are an advanced AI assistant with access to:\n",
        "1. A knowledge base about technology and science\n",
        "2. Wikipedia search capabilities\n",
        "3. Mathematical calculation tools\n",
        "4. Current date/time information\n",
        "\n",
        "Context from knowledge base:\n",
        "{context}\n",
        "\n",
        "External tool results:\n",
        "{tool_results}\n",
        "\n",
        "Current date: {current_date}\n",
        "\n",
        "User Query: {query}\n",
        "\n",
        "Instructions:\n",
        "- Use the knowledge base context when relevant\n",
        "- If you need additional information, mention what external sources would help\n",
        "- Be comprehensive but concise\n",
        "- Show your reasoning process\n",
        "- If calculations are needed, break them down step by step\n",
        "\n",
        "Response:\n",
        "\"\"\")\n",
        "\n",
        "    def _create_knowledge_base(self) -> List[Document]:\n",
        "        \"\"\"Create a comprehensive knowledge base\"\"\"\n",
        "        return [\n",
        "            Document(\n",
        "                page_content=\"Artificial Intelligence (AI) is transforming industries through machine learning, natural language processing, and computer vision. Key applications include autonomous vehicles, medical diagnosis, and financial trading.\",\n",
        "                metadata={\"topic\": \"AI\", \"category\": \"technology\"}\n",
        "            ),\n",
        "            Document(\n",
        "                page_content=\"Quantum computing uses quantum mechanical phenomena like superposition and entanglement to process information. Companies like IBM, Google, and Microsoft are leading quantum research.\",\n",
        "                metadata={\"topic\": \"quantum_computing\", \"category\": \"technology\"}\n",
        "            ),\n",
        "            Document(\n",
        "                page_content=\"Climate change is caused by greenhouse gas emissions, primarily CO2 from fossil fuels. Renewable energy sources like solar and wind are crucial for mitigation.\",\n",
        "                metadata={\"topic\": \"climate\", \"category\": \"environment\"}\n",
        "            ),\n",
        "            Document(\n",
        "                page_content=\"CRISPR-Cas9 is a revolutionary gene editing technology that allows precise DNA modifications. It has applications in treating genetic diseases and improving crops.\",\n",
        "                metadata={\"topic\": \"biotechnology\", \"category\": \"science\"}\n",
        "            ),\n",
        "            Document(\n",
        "                page_content=\"Blockchain technology enables decentralized, secure transactions without intermediaries. Beyond cryptocurrency, it has applications in supply chain, healthcare, and voting systems.\",\n",
        "                metadata={\"topic\": \"blockchain\", \"category\": \"technology\"}\n",
        "            ),\n",
        "            Document(\n",
        "                page_content=\"Space exploration has advanced with reusable rockets, Mars rovers, and commercial space travel. SpaceX, Blue Origin, and NASA are pioneering new missions.\",\n",
        "                metadata={\"topic\": \"space\", \"category\": \"science\"}\n",
        "            ),\n",
        "            Document(\n",
        "                page_content=\"Renewable energy costs have dropped dramatically. Solar and wind power are now cheaper than fossil fuels in many regions, driving global energy transition.\",\n",
        "                metadata={\"topic\": \"renewable_energy\", \"category\": \"environment\"}\n",
        "            ),\n",
        "            Document(\n",
        "                page_content=\"5G networks provide ultra-fast internet speeds and low latency, enabling IoT devices, autonomous vehicles, and augmented reality applications.\",\n",
        "                metadata={\"topic\": \"5G\", \"category\": \"technology\"}\n",
        "            )\n",
        "        ]\n",
        "\n",
        "    @tool\n",
        "    def wikipedia_search(query: str) -> str:\n",
        "        \"\"\"Search Wikipedia for additional information\"\"\"\n",
        "        try:\n",
        "            search_results = wikipedia.search(query, results=3)\n",
        "            if not search_results:\n",
        "                return f\"No Wikipedia results found for '{query}'\"\n",
        "\n",
        "            page = wikipedia.page(search_results[0])\n",
        "            summary = wikipedia.summary(search_results[0], sentences=3)\n",
        "            return f\"Wikipedia: {page.title}\\n{summary}\\nURL: {page.url}\"\n",
        "        except Exception as e:\n",
        "            return f\"Wikipedia search error: {str(e)}\"\n",
        "\n",
        "    @tool\n",
        "    def calculate(expression: str) -> str:\n",
        "        \"\"\"Perform mathematical calculations safely\"\"\"\n",
        "        try:\n",
        "            allowed_chars = set('0123456789+-*/.() ')\n",
        "            if not all(c in allowed_chars for c in expression):\n",
        "                return \"Error: Only basic mathematical operations allowed\"\n",
        "\n",
        "            result = eval(expression)\n",
        "            return f\"Calculation: {expression} = {result}\"\n",
        "        except Exception as e:\n",
        "            return f\"Calculation error: {str(e)}\"\n",
        "\n",
        "    def _format_docs(self, docs: List[Document]) -> str:\n",
        "        \"\"\"Format retrieved documents for context\"\"\"\n",
        "        if not docs:\n",
        "            return \"No relevant documents found in knowledge base.\"\n",
        "\n",
        "        formatted = []\n",
        "        for i, doc in enumerate(docs, 1):\n",
        "            formatted.append(f\"{i}. {doc.page_content}\")\n",
        "        return \"\\n\".join(formatted)\n",
        "\n",
        "    def _get_current_date(self) -> str:\n",
        "        \"\"\"Get current date and time\"\"\"\n",
        "        return datetime.now().strftime(\"%Y-%m-%d %H:%M:%S\")\n",
        "\n",
        "    def process_query(self, query: str, use_wikipedia: bool = False,\n",
        "                     calculate_expr: str = None) -> str:\n",
        "        \"\"\"Process a user query with optional external tools\"\"\"\n",
        "\n",
        "        relevant_docs = self.retriever.invoke(query)\n",
        "        context = self._format_docs(relevant_docs)\n",
        "\n",
        "        tool_results = []\n",
        "\n",
        "        if use_wikipedia:\n",
        "            wiki_keywords = self._extract_keywords(query)\n",
        "            if wiki_keywords:\n",
        "                wiki_result = self.wikipedia_search(wiki_keywords)\n",
        "                tool_results.append(f\"Wikipedia Search: {wiki_result}\")\n",
        "\n",
        "        if calculate_expr:\n",
        "            calc_result = self.calculate(calculate_expr)\n",
        "            tool_results.append(f\"Calculation: {calc_result}\")\n",
        "\n",
        "        tool_results_str = \"\\n\".join(tool_results) if tool_results else \"No external tools used\"\n",
        "\n",
        "        chain = (\n",
        "            {\n",
        "                \"context\": lambda x: context,\n",
        "                \"tool_results\": lambda x: tool_results_str,\n",
        "                \"current_date\": lambda x: self._get_current_date(),\n",
        "                \"query\": RunnablePassthrough()\n",
        "            }\n",
        "            | self.agent_prompt\n",
        "            | self.llm\n",
        "            | StrOutputParser()\n",
        "        )\n",
        "\n",
        "        return chain.invoke(query)\n",
        "\n",
        "    def _extract_keywords(self, query: str) -> str:\n",
        "        \"\"\"Extract key terms for Wikipedia search\"\"\"\n",
        "        important_words = []\n",
        "        stop_words = {'what', 'how', 'why', 'when', 'where', 'is', 'are', 'the', 'a', 'an'}\n",
        "\n",
        "        words = query.lower().split()\n",
        "        for word in words:\n",
        "            if word not in stop_words and len(word) > 3:\n",
        "                important_words.append(word)\n",
        "\n",
        "        return ' '.join(important_words[:3])\n",
        "\n",
        "    def interactive_session(self):\n",
        "        \"\"\"Run an interactive session with the agent\"\"\"\n",
        "        print(\"🤖 Advanced Nebius AI Agent Ready!\")\n",
        "        print(\"Features: Knowledge retrieval, Wikipedia search, calculations\")\n",
        "        print(\"Commands: 'wiki:<query>' for Wikipedia, 'calc:<expression>' for math\")\n",
        "        print(\"Type 'quit' to exit\\n\")\n",
        "\n",
        "        while True:\n",
        "            user_input = input(\"You: \").strip()\n",
        "\n",
        "            if user_input.lower() == 'quit':\n",
        "                print(\"Goodbye!\")\n",
        "                break\n",
        "\n",
        "            use_wiki = False\n",
        "            calc_expr = None\n",
        "\n",
        "            if user_input.startswith('wiki:'):\n",
        "                use_wiki = True\n",
        "                user_input = user_input[5:].strip()\n",
        "            elif user_input.startswith('calc:'):\n",
        "                parts = user_input.split(':', 1)\n",
        "                if len(parts) == 2:\n",
        "                    calc_expr = parts[1].strip()\n",
        "                    user_input = f\"Calculate {calc_expr}\"\n",
        "\n",
        "            try:\n",
        "                response = self.process_query(user_input, use_wiki, calc_expr)\n",
        "                print(f\"\\n🤖 Agent: {response}\\n\")\n",
        "            except Exception as e:\n",
        "                print(f\"Error: {e}\\n\")"
      ],
      "metadata": {
        "id": "UZauHJx71TBL"
      },
      "execution_count": 4,
      "outputs": []
    },
    {
      "cell_type": "code",
      "execution_count": 1,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "ezBSDr4VxU3w",
        "outputId": "97390c03-0db6-4db0-b90d-5da1d4e7492a"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "  Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m61.0/61.0 kB\u001b[0m \u001b[31m757.2 kB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m413.2/413.2 kB\u001b[0m \u001b[31m9.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m55.0/55.0 kB\u001b[0m \u001b[31m2.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.5/2.5 MB\u001b[0m \u001b[31m16.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.0/1.0 MB\u001b[0m \u001b[31m21.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m18.3/18.3 MB\u001b[0m \u001b[31m29.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m44.4/44.4 kB\u001b[0m \u001b[31m2.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m50.9/50.9 kB\u001b[0m \u001b[31m2.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[?25h  Building wheel for wikipedia (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n",
            "thinc 8.3.6 requires numpy<3.0.0,>=2.0.0, but you have numpy 1.26.4 which is incompatible.\u001b[0m\u001b[31m\n",
            "\u001b[0mEnter your Nebius API key: ··········\n",
            "=== Nebius AI Agent Demo ===\n",
            "\n",
            "Demo 1: What is artificial intelligence and how is it being used?\n",
            "Response: Artificial Intelligence (AI) refers to the development of computer systems that can perform tasks that typically require human intelligence, such as learning, problem-solving, decision-making, and perception. According to my knowledge base, AI is transforming various industries through its key applications, including:\n",
            "\n",
            "1. **Machine Learning**: enabling systems to learn from data and improve their performance over time.\n",
            "2. **Natural Language Processing**: allowing systems to understand, interpret, and generate human language.\n",
            "3. **Computer Vision**: enabling systems to interpret and understand visual data from images and videos.\n",
            "\n",
            "These technologies have numerous applications, including:\n",
            "\n",
            "* **Autonomous Vehicles**: using computer vision and machine learning to navigate and make decisions in real-time.\n",
            "* **Medical Diagnosis**: using machine learning to analyze medical images and diagnose diseases.\n",
            "* **Financial Trading**: using natural language processing and machine learning to analyze market data and make informed investment decisions.\n",
            "\n",
            "To provide a more comprehensive understanding of AI and its applications, I would like to access Wikipedia to gather information on the latest advancements and research in the field. Additionally, if specific data or statistics are required, I could utilize mathematical calculation tools to provide more detailed analysis.\n",
            "\n",
            "In summary, AI is a rapidly evolving field with far-reaching implications for various industries, and its applications continue to expand and improve as technology advances.\n",
            "\n",
            "--------------------------------------------------\n",
            "Demo 2: Tell me about quantum computing companies\n",
            "Response: To provide information about quantum computing companies, I will rely on the knowledge base context. \n",
            "\n",
            "1. **Identify Key Players**: According to the knowledge base, companies like IBM, Google, and Microsoft are leading quantum research. These companies are at the forefront of developing quantum computing technology.\n",
            "\n",
            "2. **Role in Quantum Computing**: Each of these companies has its unique contributions to quantum computing. For example, IBM has been actively involved in making quantum computing more accessible through its IBM Quantum Experience, which allows users to run quantum algorithms on a real quantum processor via the cloud. Google has also made significant advancements, including the announcement of achieving quantum supremacy with its 53-qubit Sycamore processor. Microsoft, on the other hand, offers a quantum development kit that allows developers to build quantum applications.\n",
            "\n",
            "3. **Need for Additional Information**: To provide a more comprehensive list of quantum computing companies or to delve deeper into specific aspects of their contributions (such as breakthroughs, investments, or product offerings), external sources like news articles from tech publications, official company announcements, or industry reports would be helpful. Wikipedia could also provide up-to-date information on these companies' quantum computing endeavors.\n",
            "\n",
            "4. **Calculations**: No specific calculations are required for this query. However, if we were to compare the performance metrics of different quantum processors developed by these companies, mathematical tools could be employed to analyze and compare their quantum volume, qubit count, or error rates.\n",
            "\n",
            "In conclusion, the leading quantum computing companies include IBM, Google, and Microsoft, each contributing significantly to the advancement of quantum technology. For more detailed and up-to-date information, consulting external sources such as Wikipedia or tech news outlets would be beneficial.\n",
            "\n",
            "--------------------------------------------------\n",
            "Demo 3: How does climate change affect renewable energy adoption?\n",
            "Response: To address how climate change affects renewable energy adoption, let's break down the relationship between climate change, its causes, and the role of renewable energy.\n",
            "\n",
            "1. **Climate Change Causes**: Climate change is primarily driven by greenhouse gas emissions, with CO2 from fossil fuels being a major contributor. This understanding is crucial because it highlights the need to transition away from fossil fuels to mitigate climate change.\n",
            "\n",
            "2. **Role of Renewable Energy**: Renewable energy sources like solar and wind power are vital for reducing greenhouse gas emissions. They offer a cleaner alternative to fossil fuels for electricity generation and, increasingly, for heating, cooling, and transportation.\n",
            "\n",
            "3. **Impact of Climate Change on Renewable Energy Adoption**:\n",
            "   - **Increased Awareness and Policy Support**: Climate change raises awareness about the need for sustainable energy solutions, leading to increased policy support for renewable energy. Governments implement policies like tax credits, subsidies, and renewable portfolio standards to encourage the adoption of renewable energy.\n",
            "   - **Economic Viability**: The cost of renewable energy technologies, particularly solar and wind power, has dramatically decreased over the years, making them economically viable alternatives to fossil fuels in many regions. This economic competitiveness, coupled with the urgency of addressing climate change, drives investment and adoption.\n",
            "   - **Infrastructure and Technology Innovations**: The push to combat climate change also drives innovations in renewable energy technologies and infrastructure, such as more efficient solar panels, advanced wind turbines, and better energy storage solutions. These innovations further reduce costs and increase the efficiency of renewable energy systems.\n",
            "   - **Challenges and Opportunities**: Climate change itself poses challenges to renewable energy infrastructure (e.g., more frequent extreme weather events can damage solar panels and wind turbines). However, these challenges also present opportunities for innovation in resilience and adaptation technologies.\n",
            "\n",
            "In conclusion, climate change significantly influences the adoption of renewable energy by highlighting the necessity of transitioning away from fossil fuels, driving policy and economic support for renewables, and pushing for technological innovations. The relationship is symbiotic: as renewable energy adoption increases, it helps mitigate climate change, and the urgent need to address climate change accelerates the adoption of renewable energy sources.\n",
            "\n",
            "For a more detailed analysis, accessing current data on renewable energy adoption rates, climate change policies, and technological advancements through external sources like the International Energy Agency (IEA), the National Renewable Energy Laboratory (NREL), or the Intergovernmental Panel on Climate Change (IPCC) would be beneficial.\n",
            "\n",
            "--------------------------------------------------\n",
            "\n",
            "Demo with Wikipedia:\n"
          ]
        },
        {
          "output_type": "stream",
          "name": "stderr",
          "text": [
            "/tmp/ipython-input-1-2497410691.py:163: LangChainDeprecationWarning: The method `BaseTool.__call__` was deprecated in langchain-core 0.1.47 and will be removed in 1.0. Use :meth:`~invoke` instead.\n",
            "  wiki_result = self.wikipedia_search(wiki_keywords)\n"
          ]
        },
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Response: To answer the user's query about the latest developments in space exploration, I will utilize the knowledge base context and consider additional information from external sources if necessary.\n",
            "\n",
            "From the knowledge base context, we know that space exploration has advanced significantly with the advent of reusable rockets, Mars rovers, and commercial space travel. Companies like SpaceX, Blue Origin, and NASA are at the forefront of these developments.\n",
            "\n",
            "Some of the recent advancements in space exploration include:\n",
            "\n",
            "1. **Reusable Rockets**: SpaceX has successfully launched and landed reusable rockets, reducing the cost of access to space. This technology has enabled more frequent and affordable launches.\n",
            "2. **Mars Exploration**: NASA's Mars rovers, such as Perseverance, have been exploring the Martian surface, providing valuable insights into the planet's geology and potential habitability.\n",
            "3. **Commercial Space Travel**: Private companies like SpaceX and Blue Origin are developing capabilities for commercial space travel, with SpaceX's Crew Dragon and Boeing's Starliner being examples of crew vehicles.\n",
            "\n",
            "For more information on the latest developments, I would consider searching Wikipedia for specific topics like \"SpaceX missions\" or \"NASA's Artemis program\" to get the most up-to-date information.\n",
            "\n",
            "Additionally, to stay current, I would look into recent news articles or press releases from space agencies and private space companies to get the latest updates on their missions and achievements.\n",
            "\n",
            "In conclusion, the latest developments in space exploration are characterized by advancements in reusable rocket technology, Mars exploration, and commercial space travel, driven by pioneering efforts from companies like SpaceX, Blue Origin, and NASA. For the most recent and detailed information, consulting specific Wikipedia articles or recent news sources would be beneficial. \n",
            "\n",
            "Current date confirmation: The information is being provided as of 2025-06-21 09:22:39.\n",
            "\n",
            "Demo with calculation:\n",
            "Response: To calculate the new efficiency of solar panels after a 25% improvement, we first need to understand what a 25% improvement means in numerical terms.\n",
            "\n",
            "1. **Current Efficiency**: 20%\n",
            "2. **Improvement Percentage**: 25%\n",
            "\n",
            "To find the new efficiency, we calculate 25% of the current efficiency and then add that to the current efficiency.\n",
            "\n",
            "**Step 1**: Calculate 25% of 20%.\n",
            "25% of a number = 0.25 * number\n",
            "So, 25% of 20% = 0.25 * 20% = 0.25 * 20 = 5%\n",
            "\n",
            "**Step 2**: Add the 25% improvement (5%) to the current efficiency (20%).\n",
            "New Efficiency = Current Efficiency + Improvement\n",
            "New Efficiency = 20% + 5% = 25%\n",
            "\n",
            "Therefore, if solar panel efficiency improved by 25% from a current efficiency of 20%, the new efficiency would be 25%.\n",
            "\n",
            "This improvement in solar panel efficiency is significant, as mentioned in our knowledge base, renewable energy costs have dramatically dropped, making solar and wind power cheaper than fossil fuels in many regions. Enhanced efficiency further supports the global transition to renewable energy sources, crucial for mitigating climate change by reducing CO2 emissions from fossil fuels.\n",
            "\n"
          ]
        }
      ],
      "source": [
        "if __name__ == \"__main__\":\n",
        "    agent = AdvancedNebiusAgent()\n",
        "\n",
        "    demo_queries = [\n",
        "        \"What is artificial intelligence and how is it being used?\",\n",
        "        \"Tell me about quantum computing companies\",\n",
        "        \"How does climate change affect renewable energy adoption?\"\n",
        "    ]\n",
        "\n",
        "    print(\"=== Nebius AI Agent Demo ===\\n\")\n",
        "\n",
        "    for i, query in enumerate(demo_queries, 1):\n",
        "        print(f\"Demo {i}: {query}\")\n",
        "        response = agent.process_query(query)\n",
        "        print(f\"Response: {response}\\n\")\n",
        "        print(\"-\" * 50)\n",
        "\n",
        "    print(\"\\nDemo with Wikipedia:\")\n",
        "    response_with_wiki = agent.process_query(\n",
        "        \"What are the latest developments in space exploration?\",\n",
        "        use_wikipedia=True\n",
        "    )\n",
        "    print(f\"Response: {response_with_wiki}\\n\")\n",
        "\n",
        "    print(\"Demo with calculation:\")\n",
        "    response_with_calc = agent.process_query(\n",
        "        \"If solar panel efficiency improved by 25%, what would be the new efficiency if current is 20%?\",\n",
        "        calculate_expr=\"20 * 1.25\"\n",
        "    )\n",
        "    print(f\"Response: {response_with_calc}\\n\")"
      ]
    }
  ]
}